package com.frxuexi.apps

import com.frxuexi.lib_base.ApiResp
import com.frxuexi.lib_base.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.flowOf
import javax.inject.Inject

@HiltViewModel
class AppsViewModel @Inject constructor(private val appsRepository: AppsRepository):BaseViewModel<AppIntent>() {
    override fun handleIntent(it: AppIntent) {
        when(it){
            is AppIntent.getApps->{
                httpRequest(appsRepository.getApps(it.map) as Flow<ApiResp<Any>>)
                listOf<Int>(1,2).asFlow()
            }
            is AppIntent.download->{
                download(it.url,it.file)
            }
        }
    }
}